from datetime import datetime

from sqlalchemy import BigInteger, Column, DateTime, Index, Integer, String
from config.database import Base


class ComparativeContrastLog(Base):
    """
    对比日志表
    """

    __tablename__ = 'comparative_contrast_log'

    id = Column(BigInteger, primary_key=True, autoincrement=True, comment='对比日志主键')
    source_file_name = Column(String(100, collation='utf8_general_ci'), nullable=True, default='', comment='原文件名称')
    source_file_path = Column(String(200, collation='utf8_general_ci'), nullable=True, default='', comment='原文件地址')
    target_file_name = Column(String(100, collation='utf8_general_ci'), nullable=True, default='',
                              comment='目标文件名称')
    target_file_path = Column(String(200, collation='utf8_general_ci'), nullable=True, default='',
                              comment='目标文件地址')
    operator = Column(String(50, collation='utf8_general_ci'), nullable=True, default='', comment='操作人员')
    host_ip = Column(String(128, collation='utf8_general_ci'), nullable=True, default='', comment='主机地址')
    operating_location = Column(String(255, collation='utf8_general_ci'), nullable=True, default='', comment='操作地点')
    request_param = Column(String(2000, collation='utf8_general_ci'), nullable=True, default='', comment='请求参数')
    operation_time: datetime = Column(DateTime, nullable=True, default=datetime.now(), comment='操作时间')

    idx_comparative_contrast_log_ot = Index('idx_comparative_contrast_log_ot', operation_time)
